//var userAagent = navigator.userAgent;
//
//alert(userAagent);

//设置sessionStroage的值
if(!sessionStorage.getItem("userGuid")){
    if(localStorage.getItem("isRem")=="1") {
        if(localStorage.getItem("userGuid")) {
            var us = $.parseJSON(localStorage.getItem("user"));
            sessionStorage.setItem("userGuid",localStorage.getItem("userGuid"));
            sessionStorage.setItem("user",localStorage.getItem("user"));
            $('#cityName').html(us.orgName);
        }
    }
}

/**
 * 清空结果显示DIV内容
 * */
 
function reset() {
    //TODO:清空结果显示DIV内容
}
/**
 * 显示Toast消息,
 * @param msg Toast显示内容
 * @duration Toast显示时间[可行，默认显示4s]
 */
function toast(msg, duration) {
    var _toast = $("#os-toast");
    if (0 == _toast.length) {
        _toast = $("<div id=\"os-toast\" class=\"toast\"></div>");
        $("body").append(_toast);
    }
    if (_toast.is(":hidden")) {
        _toast.empty().html(msg).addClass("show");
        setTimeout(function () {
            _toast.removeClass("show");
        }, duration ? duration : 2000);
    }
}
/**
 * 页面加载遮罩层
 * @param msg
 */
function loading(msg) {
    var _loading = $("#os-loading");
    if (0 == _loading.length) {
        _loading = $("<div id=\"os-loading\" class=\"pg-load\"><div class=\"load-msg\">"+(msg?msg:"正在加载")+"...</div></div>");
        $("body").append(_loading);
    }
    if (_loading.is(":hidden")) {
        $("#os-loading").fadeIn(100);
    }
}
/**
 * 结束加载，关闭遮罩层
 */
function finish(msg) {
    $("#os-loading").fadeOut(100);
    if (msg)
        toast(msg);
    //else
        //toast("查询失败");
}
function getServerPreFix(){
	return "http://172.17.118.41:8081/MicroService/";
}


function callAjaxPost(url,data,succCallBack,errorCallBack)
{
    $.ajax({
        type: 'POST',
        url: url,
        data: data,
        contentType: 'application/json',
        success: function (resp) {
            succCallBack(resp);

        },
        error:function(resp)
        {
            errorCallBack(resp);
        }

    });
}


function callAjaxGet(url,succCallBack,errorCallBack)
{
    $.ajax({
        type: 'GET',
        url: url,
        success: function (resp) {
            succCallBack(resp);

        },
        error:function(resp)
        {
            errorCallBack(resp);
        }

    });
}
function clearYjSession(){
    sessionStorage.removeItem("caseGuid");
    sessionStorage.removeItem("yjMethod");
    sessionStorage.removeItem("country");
    sessionStorage.removeItem("pcs");
    sessionStorage.removeItem("city");
    sessionStorage.removeItem("pcsCode");
}

Date.prototype.plusYear = function (src) {
    var year = this.getFullYear();

    var month = this.getMonth();

    var date = this.getDate()

    var newYear = parseInt(year)-src;

    var newDate = new Date(newYear,month,date);
    return newDate;

}